package com.xyw.his00.dto;

import com.xyw.his00.pojo.dbpojo.CheckRequest;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


@Data
public class CheckRequestDTO {
    protected Integer id;

    protected Integer registerId;//挂号id

    protected Integer medicalTechnologyId;

    protected String checkInfo;//检查信息

    protected String checkPosition;//

    protected String creationTime;

    protected Integer checkEmployeeId;//查检医生id

    protected Integer inputcheckEmployeeId;//输结果医生id

    protected String checkTime;//检查时间

    protected String checkResult;//结果

    protected String checkState;//状态（已开立，已缴费，已经出了结果，已经退费，已作废）

    protected String checkRemark;
    public CheckRequestDTO(){

   }

    public CheckRequestDTO(Integer id, Integer registerId, Integer medicalTechnologyId, String checkInfo, String checkPosition, String creationTime, Integer checkEmployeeId, Integer inputcheckEmployeeId, String checkTime, String checkResult, String checkState, String checkRemark) {
        this.id = id;
        this.registerId = registerId;
        this.medicalTechnologyId = medicalTechnologyId;
        this.checkInfo = checkInfo;
        this.checkPosition = checkPosition;
        this.creationTime = creationTime;
        this.checkEmployeeId = checkEmployeeId;
        this.inputcheckEmployeeId = inputcheckEmployeeId;
        this.checkTime = checkTime;
        this.checkResult = checkResult;
        this.checkState = checkState;
        this.checkRemark = checkRemark;
    }

    public static CheckRequest revert(CheckRequestDTO checkRequestDTO)throws NullPointerException{
        return  new CheckRequest(checkRequestDTO.getId(),
                checkRequestDTO.getRegisterId(),
                checkRequestDTO.getMedicalTechnologyId(),
                checkRequestDTO.getCheckInfo(),
                checkRequestDTO.getCheckPosition(),
                checkRequestDTO.getCreationTime()==null?null:  LocalDateTime.parse(checkRequestDTO.getCreationTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                checkRequestDTO.getCheckEmployeeId(),
                checkRequestDTO.getInputcheckEmployeeId(),
                checkRequestDTO.getCheckTime()==null?null:  LocalDateTime.parse(checkRequestDTO.getCheckTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                checkRequestDTO.getCheckResult(),
                checkRequestDTO.getCheckState(),
                checkRequestDTO.getCheckRemark());
    }
    public static CheckRequest[] revert(CheckRequestDTO[] checkRequestDTOS){
        if (checkRequestDTOS == null) {
            return null;
        }
        CheckRequest[] checkRequests = new CheckRequest[checkRequestDTOS.length];
        for (int i = 0; i < checkRequestDTOS.length; i++) {
            checkRequests[i] = revert(checkRequestDTOS[i]);
        }
        return checkRequests;
    }
}
